//
//  YKLGLoginViewController.m
//  LiveGather
//
//  Created by Yue Shen on 16/9/12.
//  Copyright © 2016年 Yue Shen. All rights reserved.
//

#import "YKLGLoginViewController.h"
#import "HTTPService.h"
#import "YKLGUser.h"

#define HEIGHT_CONTAINER 100.6
@interface YKLGLoginViewController ()
{
    UIView *ui_view_container;
    UIView *ui_view_seperator;
    UIImageView *ui_img_logo;
    UIImageView *ui_img_user_name_icon;
    UIImageView *ui_img_pwd_icon;
    UITextField *ui_tf_user_name;
    UITextField *ui_tf_pwd;
    UIButton *ui_btn_login;
}
@end

@implementation YKLGLoginViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    NSLog(@"123");
}

- (void)setupUI {
    self.view.backgroundColor = BACKCOLOR;
    WS(ws);
    ui_img_logo = [UIImageView new];
    [ui_img_logo setImage:[UIImage imageNamed:@"live_logo"]];
    [self.view addSubview:ui_img_logo];
    [ui_img_logo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(75*2);
        make.height.mas_equalTo(12.5*2);
        make.top.mas_equalTo(37.5*2);
        make.centerX.equalTo(ws.view);
    }];
    
    ui_view_container = [UIView new];
    ui_view_container.backgroundColor = WHITECOLOR;
    [self.view addSubview:ui_view_container];
    [ui_view_container mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(HEIGHT_CONTAINER);
        make.left.mas_equalTo(7.5*2);
        make.right.mas_equalTo(-7.5*2);
        make.top.equalTo(ui_img_logo.mas_bottom).offset(36.2*2);
        make.centerX.equalTo(ws.view);
    }];
   
    ui_view_seperator = [UIView new];
    ui_view_seperator.backgroundColor = GRAYCOLOR;
    [ui_view_container addSubview:ui_view_seperator];
    [ui_view_seperator mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(HEIGHT_CONTAINER/2);
        make.height.mas_equalTo(0.5);
    }];
    
    ui_img_user_name_icon = [UIImageView new];
    [ui_img_user_name_icon setImage:[UIImage imageNamed:@"account_number"]];
    [ui_view_container addSubview:ui_img_user_name_icon];
    [ui_img_user_name_icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(18);
        make.left.mas_equalTo(7.5*2);
        make.top.mas_equalTo(8.2*2);
    }];
    
    ui_img_pwd_icon = [UIImageView new];
    [ui_img_pwd_icon setImage:[UIImage imageNamed:@"password"]];
    [ui_view_container addSubview:ui_img_pwd_icon];
    [ui_img_pwd_icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(18);
        make.left.mas_equalTo(7.5*2);
        make.bottom.mas_equalTo(-7.5*2);
    }];
    
    ui_btn_login = [UIButton new];
    ui_btn_login.layer.cornerRadius = 4;
    ui_btn_login.layer.masksToBounds = YES;
    [ui_btn_login setTitle:@"登录" forState:UIControlStateNormal];
    [self.view addSubview:ui_btn_login];
    [ui_btn_login setBackgroundColor:BLUECOLOR];
    [ui_btn_login mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(ws.view);
        make.top.equalTo(ui_view_container.mas_bottom).offset(15*2);
        make.left.mas_equalTo(7.5*2);
        make.right.mas_equalTo(-7.5*2);
        make.height.mas_equalTo(25*2);
    }];
    [ui_btn_login addTarget:self action:@selector(login) forControlEvents:UIControlEventTouchUpInside];
    
    ui_tf_user_name = [UITextField new];
    ui_tf_user_name.placeholder = @"优酷账号";
    [ui_view_container addSubview:ui_tf_user_name];
    [ui_tf_user_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(ui_img_user_name_icon);
        make.left.equalTo(ui_img_user_name_icon.mas_right).offset(8);
        make.right.mas_equalTo(-8);
    }];
    
    ui_tf_pwd= [UITextField new];
    ui_tf_pwd.placeholder = @"密码";
    [ui_view_container addSubview:ui_tf_pwd];
    [ui_tf_pwd mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(ui_img_pwd_icon);
        make.left.equalTo(ui_img_pwd_icon.mas_right).offset(8);
        make.right.mas_equalTo(-8);
    }];
}

- (void)login {
    [[HTTPService Instance] mobileGET:@"" path:@"" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        [[YKLGUser shareInstance]setUserName:@"" avatarUrl:@"" token:@"" email:@""];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];
}
@end
